// Parameter library

#ifndef H_PARAMETER
#define H_PARAMETER

#include "Arduino.h"

#define PARA_CHECK (57+5) // change this if you change parameter file class

class Parameter
{
private:
  int addr; 
public:

  /**************************************************************************************/


  boolean checkVersion()
  {
    addr=1; // current address to write
    return (EEPROM.read(0)==PARA_CHECK);
  }

  void setVersion()
  {
    addr=1; // current address to write
    EEPROM.write(0,PARA_CHECK);  
  }

  float readFloat()
  {
    float v;

    for(byte i=0;i<4;i++)
      ((byte*)&v)[i]=EEPROM.read(addr++);

    return v;
  }

  void writeFloat(float v)
  {
    for(byte i=0;i<4;i++)
      EEPROM.write(addr++,  ((byte*)&v)[i]  );
    if (addr>511) Serial.println(F("Error too much EEPROM DATA in parameter.h"));
  }

} 
para;

#endif







